#include "rightitemdelegate.h"

RightItemDelegate::RightItemDelegate(QObject *parent) :
  AbstractDelegate(parent)
{
}

void RightItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
  AbstractDelegate::paint(painter,option,index);

  painter->save();
  QLinearGradient grad(option.rect.topLeft().x(),option.rect.topLeft().y(),option.rect.topLeft().x()+8,option.rect.topLeft().y());
  grad.setColorAt(0,QColor(0,0,0,200));
  grad.setColorAt(1,QColor(0,0,0,0));
  painter->setPen(QPen(Qt::transparent));
  painter->setBrush(QBrush(grad));
  painter->setOpacity(0.8);
  painter->drawRect(option.rect.topLeft().x(),option.rect.topLeft().y(),8,option.rect.height());
  painter->restore();
}

int RightItemDelegate::fontSize(const QRect &r) const
{
  return 19;
}

int RightItemDelegate::leftMargin(const QRect &r) const
{
  return 77;
}

QBrush RightItemDelegate::rectBrush(const QRect &r) const
{
  return Qt::transparent;
}

QBrush RightItemDelegate::selectedRectBrush(const QRect &r) const
{
  QLinearGradient grad(r.topLeft(),r.bottomLeft());
  QColor c1(200,200,200,200);
  QColor c2(180,180,180,200);
  grad.setColorAt(0,c1);
  grad.setColorAt(0.4,c2);
  grad.setColorAt(0.6,c2);
  grad.setColorAt(1,c1);
  return QBrush(grad);
}

QPen RightItemDelegate::rectPen(const QRect &r) const
{
  return QPen(Qt::transparent);
}

QPen RightItemDelegate::selectedRectPen(const QRect &r) const
{
  return QPen(QColor(180,180,180,155));
}

QPen RightItemDelegate::textPen(const QRect &r) const
{
  return QColor(250,250,250);
}

QPen RightItemDelegate::selectedTextPen(const QRect &r) const
{
  return QColor(54,54,54);
}

QPen RightItemDelegate::disabledTextPen(const QRect &r) const
{
  return QColor(150,150,150);
}
